<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>项目审核管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../assets/layui/css/layui.css" media="all">
</head>
<body>
<div style="padding: 10px;">
    <from class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width: auto;">项目名称</label>
                <div class="layui-input-inline" style="width: 200px;">
                    <input type="text" id="projectName" name="projectName" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label" style="width: auto;">施工单位名称</label>
                <div class="layui-input-inline" style="width: 200px;">
                    <input type="text" id="companyName" name="companyName" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <button class="layui-btn layui-btn-normal" data-type="search" id="btnSearch">查询</button>
            </div>
        </div>
    </from>
</div>
<table class="layui-table" lay-filter="tbFliter" id="tbData" style="margin-top: -25px;">
</table>
<script type="text/html" id="barList">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">审核</a>
</script>
<script src="../assets/layui/layui.js"></script>
<script>
    layui.config({
        base: '../js/'
    });
    layui.use(['jquery','table','common','laydate'], function () {
        var table = layui.table,
            common=layui.common,
            laydate=layui.laydate,
            $ = layui.jquery,
            active = {
                search: function () {
                    table.reload("tbOptions", {
                        where: {
                            projectName: $("#projectName").val(),
                            companyName: $("#companyName").val(),
                            status:1,
                            page:1
                        }
                    });
                }
            };
        var op=common.getUrlParam("op");

        //表格初始化
        table.render({
            elem: '#tbData'
            , skin: 'row'
            , url: '../project/checklist'
            , page: true
            , cols: [[
                {field: 'id', title: '序号', width: 70}
                ,{field: 'projectname', title: '项目名称'}
                ,{field: 'projecttype', title: '项目类型'}
                ,{field: 'projectadress', title: '项目地址'}
                ,{field: 'projectstatus', title: '工程状态'}
                ,{field: 'companyname', title: '施工单位名称'}
                , {field: 'projectperson', title: '项目负责人'}
                , {field: 'projectpersonphone', title: '项目负责人电话'}
                , {field: 'status', title: '状态', templet: function(d){
                    if(d.status==0){
                        return "";
                    }else if(d.status==1){
                        return "待审批";
                    }else if(d.status==2){
                        return "审核通过";
                    }else if(d.status==3){
                        return "审核不通过";
                    }
                }}
                , {field: 'reason', title: '原因', templet: function(d){
                    if(d.reason==null){
                        return '';
                    }else {
                        return '<label title="'+d.reason+'">'+(d.reason.length>10?d.reason.substring(0,10):d.reason)+'</label>';
                    }
                }}
                , {field: 'operation', title: '操作', width: 100,templet: function(d){
                    if(d.status==1){
                        return '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">审核</a>';
                    }
                    return "";
                }}
//                , {field: 'operation', title: '操作', width: 150, toolbar: '#barList'}
            ]]
            , limits: [10, 20, 50]
            , where: {
                projectName: $("#projectName").val(),
                companyName: $("#companyName").val(),
                op: op
            }
            , id: 'tbOptions'
        });

        table.on('tool(tbFliter)', function (obj) {
            var data = obj.data; //获得当前行数据
            var id = data.projectid;
            var layEvent = obj.event; //获得 lay-event
            if (layEvent === 'edit') { //编辑
                common.layer_show("项目信息审批", 'projectCheck.html?id=' + id,'100%','100%');
            }
        });

        //按钮事件绑定
        $('.layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
</body>
</html>